# Definition for singly-linked list.
class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next
head=ListNode(1)
head.next=ListNode(2)
head.next.next=ListNode(3)
head.next.next.next=ListNode(4)
#重排链表
def reorderList(head) -> None:
        """
        Do not return anything, modify head in-place instead.
        """
        headPro=head
        nodeList=[]
        while headPro:
            nodeList.append(headPro)
            headPro=headPro.next
        print(nodeList)
        nodeNum=len(nodeList)-1
        print(nodeNum>>1)
        index=0
        headPro=head
        while headPro and index<=(nodeNum>>1):
            temp=nodeList[nodeNum-index]
            temp.next=headPro.next
            headPro.next=temp
            headPro=temp.next
            index+=1
        headPro.next=None
        headPro=head
        while headPro:
            print(headPro.val)
            headPro=headPro.next


reorderList(head)